package com.whc.gulimall.order.designPattern.strategy;

import cn.hutool.core.util.ObjectUtil;
import com.alipay.api.AlipayApiException;
import com.whc.gulimall.order.vo.PayVo;

/**
 * @author angaoen
 */
public class Pay {

    /**
     * 支付策略选择
     */
    private PayStrategy payStrategy;

    public Pay(PayStrategy payStrategy) {
        this.payStrategy = payStrategy;
    }

    public String pay(PayVo vo) throws Exception {
        if (ObjectUtil.isNotNull(payStrategy) && ObjectUtil.isNotNull(vo)) {
            return payStrategy.pay(vo);
        } else {
            throw new AlipayApiException();
        }
    }
}
